fix: Use dynamic partition data source to determine DNS suffix for Karpenter EC2 pass role permission #3193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix Karpenter module iam policy passrole to ec2 api bug. Related issue: #3190
Motivation and Context
The current iam:PassRole action condition only works for ec2.amazonaws.com, can't work for ec2.amazonaws.com.cn
If use karpenter module at AWS CN, it would throw the unauthorized error when Karpenter pods try to create new instances, the Karpenter iam role can't pass to Karpenter node iam role because of the ec2 api(ec2.amazonaws.com) is not correct.
Resolves Karpenter failed to launch new EC2 instances due to controller IAM policy lacks support for China regions #3190
`
statement {
sid = "AllowPassingInstanceRole"
resources = var.create_node_iam_role ? [aws_iam_role.node[0].arn] : [var.node_iam_role_arn]
actions = ["iam:PassRole"]
condition {
test = "StringEquals"
variable = "iam:PassedToService"
values = ["ec2.amazonaws.com"]
}
}
`
Breaking Changes
No, it does not break backwards compatibility with the current major version.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request